home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / x11 / x-misc.el < prev    next >
Encoding:
Text File  |  1995-08-18  |  2.9 KB  |  75 lines

  1. ;;; x-misc.el --- miscellaneous X functions.
  2.  
  3. ;;; Copyright (C) 1995 Sun Microsystems.
  4.  
  5. ;; Author: Ben Wing <wing@netcom.com>
  6.  
  7. ;; This file is part of XEmacs.
  8.  
  9. ;; XEmacs is free software; you can redistribute it and/or modify it
  10. ;; under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 2, or (at your option)
  12. ;; any later version.
  13.  
  14. ;; XEmacs is distributed in the hope that it will be useful, but
  15. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. ;; General Public License for more details.
  18.  
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  21. ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. (defun x-bogosity-check-resource (name class type)
  24.   "Check for a bogus resource specification."
  25.   (let ((bogus (x-get-resource
  26.         (concat "__no-such-friggin-locale__." name)
  27.         (concat "__No-such-friggin-widget__." class)
  28.         type 'global nil t)))
  29.     (if bogus
  30.     (display-warning
  31.      'resource
  32.      (format "Bad resource specification encountered: something like
  33.      Emacs*%s: %s
  34. You should replace the * with a . in order to get proper behavior when
  35. you use the specifier and/or `set-face-*' functions." name bogus)))))
  36.  
  37. (defun x-init-specifier-from-resources (specifier type locale
  38.                           &rest resource-list)
  39.   "Initialize a specifier from the resource database.
  40. LOCALE specifies the locale that is to be initialized and should be
  41. a frame, a device, or 'global.  TYPE is the type of the resource and
  42. should be one of 'string, 'boolean, 'integer, or 'natnum.  The
  43. remaining args should be conses of names and classes of resources
  44. to be examined.  The first resource with a value specified becomes
  45. the spec for SPECIFIER in LOCALE. (However, if SPECIFIER already
  46. has a spec in LOCALE, nothing is done.) Finally, if LOCALE is 'global,
  47. a check is done for bogus resource specifications."
  48.   (if (eq locale 'global)
  49.       (mapcar #'(lambda (x)
  50.           (x-bogosity-check-resource (car x) (cdr x) type))
  51.           resource-list))
  52.   (if (not (specifier-spec-list specifier locale))
  53.       (catch 'done
  54.     (while resource-list
  55.       (let* ((name (caar resource-list))
  56.          (class (cdar resource-list))
  57.          (resource
  58.           (x-get-resource name class type locale nil t)))
  59.         (if resource
  60.         (progn
  61.           (add-spec-to-specifier specifier resource locale)
  62.           (throw 'done t))))
  63.       (setq resource-list (cdr resource-list))))))
  64.  
  65. (defun x-get-resource-and-bogosity-check (name class type &optional locale)
  66.   (x-bogosity-check-resource name class type)
  67.   (x-get-resource name class type locale nil t))
  68.  
  69. ;; #### this function is not necessary.
  70. (defun x-get-resource-and-maybe-bogosity-check (name class type &optional
  71.                              locale)
  72.   (if (eq locale 'global)
  73.       (x-bogosity-check-resource name class type))
  74.   (x-get-resource name class type locale nil t))
  75.